const path=require('path');
const express=require('express');
const app=express();
const indexData=require("./public/mock/index.json")
const cityData=require("./public/mock/city.json")
const detailData=require("./public/mock/detail.json")

const apiRoutes=express.Router()
app.use('/api',apiRoutes)

function resolve(dir){
    return path.join(__dirname,dir)
}
module.exports={
    lintOnSave:true,
    chainWebpack:(config)=>{
        config.resolve.alias
        .set('@',resolve('src'))
        .set('styles',resolve('src/assets/styles'))
        .set('components',resolve('src/components'))
        .set('common',resolve("src/common"))
    },
    publicPath:"project/travel",
    devServer: {
        proxy: {
          '/api/travel': {
            target: 'http://localhost',
            ws: true,
            changeOrigin: true,
            pathRewrite:{
                "^/api/travel":"/api/travel"
            }
          }
        }
        // port:8080,
        // open:true,
        // before:function(app){
        //     app.get('/api/index.json',function(req,res){
        //         res.json(indexData);
        //     });
        //     app.get("/api/city.json",function(req,res){
        //         res.json(cityData)
        //     });
        //     app.get("/api/detail.json",function(req,res){
        //         res.json(detailData)
        //     })
        // }
    }
}